package com.backend.romimgview.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.backend.common.annotation.Log;
import com.backend.common.core.controller.BaseController;
import com.backend.common.core.domain.AjaxResult;
import com.backend.common.enums.BusinessType;
import com.backend.romimgview.domain.RomimgView;
import com.backend.romimgview.service.IRomimgViewService;
import com.backend.common.utils.poi.ExcelUtil;
import com.backend.common.core.page.TableDataInfo;

/**
 * 房间图片管理Controller
 * 
 * @author fusi
 * @date 2024-10-06
 */
@RestController
@RequestMapping("/romimgview/romimgview")
public class RomimgViewController extends BaseController
{
    @Autowired
    private IRomimgViewService romimgViewService;

    /**
     * 查询房间图片管理列表
     */
    @PreAuthorize("@ss.hasPermi('romimgview:romimgview:list')")
    @GetMapping("/list")
    public TableDataInfo list(RomimgView romimgView)
    {
        startPage();
        List<RomimgView> list = romimgViewService.selectRomimgViewList(romimgView);
        return getDataTable(list);
    }

    /**
     * 导出房间图片管理列表
     */
    @PreAuthorize("@ss.hasPermi('romimgview:romimgview:export')")
    @Log(title = "房间图片管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RomimgView romimgView)
    {
        List<RomimgView> list = romimgViewService.selectRomimgViewList(romimgView);
        ExcelUtil<RomimgView> util = new ExcelUtil<RomimgView>(RomimgView.class);
        util.exportExcel(response, list, "房间图片管理数据");
    }

    /**
     * 获取房间图片管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('romimgview:romimgview:query')")
    @GetMapping(value = "/{imageRoomId}")
    public AjaxResult getInfo(@PathVariable("imageRoomId") Long imageRoomId)
    {
        return success(romimgViewService.selectRomimgViewByImageRoomId(imageRoomId));
    }

    @PreAuthorize("@ss.hasPermi('romimgview:romimgview:query')")
    @GetMapping(value = "/room/{roomId}")
    public AjaxResult getNewRoom(@PathVariable("roomId") Long roomId)
    {
        return success(romimgViewService.selectRoomByRoomId(roomId));
    }

    @PreAuthorize("@ss.hasPermi('romimgview:romimgview:query')")
    @GetMapping(value = "/image/{imageId}")
    public AjaxResult getNewImage(@PathVariable("imageId") Long imageId)
    {
        return success(romimgViewService.selectImageByImageId(imageId));
    }

    /**
     * 新增房间图片管理
     */
    @PreAuthorize("@ss.hasPermi('romimgview:romimgview:add')")
    @Log(title = "房间图片管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RomimgView romimgView)
    {
        return toAjax(romimgViewService.insertRomimgView(romimgView));
    }

    /**
     * 修改房间图片管理
     */
    @PreAuthorize("@ss.hasPermi('romimgview:romimgview:edit')")
    @Log(title = "房间图片管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RomimgView romimgView)
    {
        return toAjax(romimgViewService.updateRomimgView(romimgView));
    }

    /**
     * 删除房间图片管理
     */
    @PreAuthorize("@ss.hasPermi('romimgview:romimgview:remove')")
    @Log(title = "房间图片管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{imageRoomIds}")
    public AjaxResult remove(@PathVariable Long[] imageRoomIds)
    {
        return toAjax(romimgViewService.deleteRomimgViews(imageRoomIds));
    }
}
